package com.wsm.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsm.common.annotation.RedisCache;
import com.wsm.common.domain.VisitDO;
import com.wsm.common.mapper.VisitMapper;
import com.wsm.common.service.VisitService;
import com.wsm.common.utils.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 访客记录表
 *
 * @author wangshimin
 * @email wangshiminhome@foxmail.com
 * @date 2020-02-17 12:07:19
 * @description : 访客记录表
 */
@Service
public class VisitServiceImpl extends ServiceImpl<VisitMapper, VisitDO> implements VisitService {
	@Autowired
	private VisitMapper visitMapper;

	@Override
	@RedisCache(value = "Visit", flush = false, expire = 30L, unit = TimeUnit.MINUTES)
	public List<VisitDO> list(Map<String, Object> map) {
		return visitMapper.list(map);
	}

	@Override
	@RedisCache(value = "Visit", flush = false, expire = 30L, unit = TimeUnit.MINUTES)
	public int count(Map<String, Object> map) {
		return visitMapper.count(map);
	}

	@Override
	@RedisCache(value = "Visit", flush = true, expire = 30L, unit = TimeUnit.MINUTES)
	public int orSave(VisitDO visit) {
		visit.setId(SnowFlake.nextId());
		return visitMapper.orSave(visit);
	}

	@Override
	@RedisCache(value = "Visit", flush = true, expire = 30L, unit = TimeUnit.MINUTES)
	public int update(VisitDO visit) {
		return visitMapper.orUpdate(visit);
	}

	@Override
	@RedisCache(value = "Visit", flush = true, expire = 30L, unit = TimeUnit.MINUTES)
	public int remove(Long id) {
		return visitMapper.remove(id);
	}

	@Override
	@RedisCache(value = "Visit", flush = true, expire = 30L, unit = TimeUnit.MINUTES)
	public int batchRemove(Long[] ids) {
		return visitMapper.batchRemove(ids);
	}


}
